***********************************************
***** Pandora's Rules in the Laboratory  ******
***********************************************

** Run this file to replicate results shown in Tables 1, 2, 4, 7, 8, 10, A1, A2. 
** After executing the commands below, the findings were manually transferred into the relevant Tables. ** In some cases, the STATA package outreg2 was used. 
** Input file: Main.dta 


** Change working directory
cd ".."

use "Main.dta", clear


** Table 1, Panel B
bys session: sum pos2 

** Table 2 
*per session

*1-100 rounds
bys session: tab openfirst
*51-100 rounds
bys session: tab openfirst if Period>50

**Per treatment

*1-100 rounds
bys treatment: tab openfirst 
*51-100 rounds
bys treatment: tab openfirst   if Period>50


** Table 4
quietly probit openfirst treatment       i.Period , vce(cluster ID2)
margins, dydx (treatment) post
quietly probit openfirst treatment pos2  i.Period , vce(cluster ID2)
margins, dydx (treatment pos2) post
quietly probit openfirst treatment pos2  inter i.Period , vce(cluster ID2)
margins, dydx (treatment pos2 inter) post


** Table 7
*Per session
*First move - Rounds 1-100
bys session: tab correct1_r0
*First move - Rounds 51-100
bys session: tab correct1_r0  if Period>50

*Full moves - Rounds 1-100
bys session: tab correct2_r0 
*Full moves - Rounds 51-100
bys session: tab correct2_r0  if Period>50

*Per treatment
*First move - Rounds 1-100
bys treatment: tab correct1_r0
*First move - Rounds 51-100
bys treatment: tab correct1_r0  if Period>50

*Full moves - Rounds 1-100
bys treatment: tab correct2_r0 
*Full moves - Rounds 51-100
bys treatment: tab correct2_r0  if Period>50



*Table 8
quietly regress correct1_r0 Period , vce(cluster ID2)
estimates store m6a
quietly regress correct1_r0 Period if treatment==0, vce(cluster ID2)
estimates store m7a
quietly regress correct1_r0 Period if treatment==1, vce(cluster ID2)
estimates store m8a
quietly regress correct2_r0 Period, vce(cluster ID2)
estimates store m6
quietly regress correct2_r0 Period if treatment==0, vce(cluster ID2)
estimates store m7
quietly regress correct2_r0 Period if treatment==1, vce(cluster ID2)
estimates store m8

outreg2 [m6a] using table8.tex, replace ctitle(1)   keep(correct1_r0 Period)   tdec(4) bdec(4)
outreg2 [m7a] using table8.tex, append  ctitle(2)   keep(correct1_r0 Period)   tdec(4) bdec(4)
outreg2 [m8a] using table8.tex, append  ctitle(3)   keep(correct1_r0 Period)   tdec(4) bdec(4)
outreg2 [m6]  using table8.tex, append  ctitle(4)   keep(correct2_r0 Period)   tdec(4) bdec(4)
outreg2 [m7]  using table8.tex, append  ctitle(5)   keep(correct2_r0 Period)   tdec(4) bdec(4)
outreg2 [m8]  using table8.tex, append  ctitle(6)   keep(correct2_r0 Period)   tdec(4) bdec(4)



*Table 10
quietly regress Payoff treatment i.Period , vce(cluster ID2)
estimates store m4
quietly regress Payoff treatment pos2 i.Period , vce(cluster ID2)
estimates store m5
outreg2 [m4] using table10.tex, replace ctitle(1)   keep(Payoff treatment pos2)    tdec(4) bdec(4)
outreg2 [m5] using table10.tex, append  ctitle(2)   keep(Payoff treatment pos2)    tdec(4) bdec(4)


***********************
***    Appendix     ***
***********************


* Table A1 
quietly regress openedboxes treatment  i.Period, vce(cluster ID2)
estimates store m9
outreg2 [m9] using table_a1.tex, replace ctitle(1) keep(openedboxes treatment)   tdec(4) bdec(4)


* Table A2 
** After executing the ''collapse'' command, we manually transfered the data into the relevant Tables. 
*Panel A: per treatment payoffs
** Full periods
preserve 
collapse Payoff, by(treatment session) 
replace  Payoff = Payoff*100
restore

**Averages
preserve 
collapse Payoff, by(treatment) 
replace  Payoff = Payoff*100
restore


** Half periods
preserve 
collapse Payoff if Period>50, by(treatment session) 
replace Payoff = Payoff*50
restore

**Averages
preserve 
collapse Payoff if Period>50, by(treatment) 
replace Payoff = Payoff*50
restore


*Panel B: per subject payoffs
** Full periods
preserve 
collapse Payoff, by(treatment session) 
replace Payoff = Payoff*100/15
restore

*averages
preserve 
collapse Payoff, by(treatment) 
replace Payoff = Payoff*100/15
restore


** Half periods
preserve 
collapse Payoff if Period>50, by(treatment session) 
replace  Payoff = Payoff*50/15
restore

**averages 
preserve 
collapse Payoff if Period>50, by(treatment) 
replace Payoff = Payoff*50/15
restore








************* End of Do file ***************
